package com.firefly.web.controller.api.common;

import com.firefly.web.controller.api.ApiRestController;
import com.firefly.web.utils.CodeUtils;
import com.firefly.dao.dto.login.CodeSendDto;
import com.firefly.dao.vo.login.CodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * @description: 获取验证码
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2023/2/10
 **/
@ApiRestController("code")
public class CodeController {
    private final CodeUtils codeUtils;
    @Autowired
    public CodeController(CodeUtils codeUtils){
        this.codeUtils = codeUtils;
    }
    @PostMapping("send")
    public CodeVo postSend(@Validated CodeSendDto request){
        codeUtils.havCode(request.getPhone());
        String code = codeUtils.getCode(request.getPhone());
        CodeVo result = new CodeVo(code);
        return result;
    }
}
